<?php

namespace App;

use Illuminate\Database\Eloquent\Model;

/**
 * App\UserMoneyLog
 *
 * @property int $id
 * @property int|null $user_id 用户id
 * @property int|null $leader_id 上级id
 * @property int|null $type 0 推广 1 团队
 * @property int|null $order_pay_id 订单id
 * @property \Carbon\Carbon|null $created_at
 * @property \Carbon\Carbon|null $updated_at
 * @property float|null $price 金钱 分为单位
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereCreatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereLeaderId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereOrderPayId($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog wherePrice($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereType($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereUpdatedAt($value)
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereUserId($value)
 * @mixin \Eloquent
 * @property int|null $status 0未结算 1已结算
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereStatus($value)
 * @property-read \Illuminate\Database\Eloquent\Collection|\App\OrderGoods[] $good
 * @property-read \App\OrderPay $order
 * @property-read \App\User|null $user
 * @property string|null $refund_status 是否退款
 * @method static \Illuminate\Database\Eloquent\Builder|\App\UserMoneyLog whereRefundStatus($value)
 */
class UserMoneyLog extends Model
{
    protected $table='user_money_log';
    const REFUND_STATUS_PENDING = 'pending';
    const REFUND_STATUS_APPLIED = 'applied';
    public static $refundStatusMap = [
        self::REFUND_STATUS_PENDING    => '未退款',
        self::REFUND_STATUS_APPLIED    => '退款',
    ];
    public function order(){
        return $this->hasOne('App\OrderPay','order_pay_id','order_pay_id');
    }
    public function good(){
        return $this->hasMany('App\OrderGoods','order_pay_id','order_pay_id');
    }
    public function user(){
        return $this->belongsTo('App\User','user_id');
    }
}
